﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web;

using OgilvyOne.BLL;
using OgilvyOne.UKNow.Model;
using OgilvyOne.UKNow.IDAL;
using OgilvyOne.UKNow.DAL;
using OgilvyOne.UKNow.DALFactory;
using ECCIT;
using ECCIT.Data;

namespace OgilvyOne.UKNow.BLL
{
    public  class CmsProxy
    {
        public static string GetHtml(CmsVoWrapper vo)
        {
            //if (vo.Aid > 0)
            //{
            //    //内容
            //    EventsBLL bll = new EventsBLL(vo.LanguageID);
            //    vo.EventsModel = bll.selEvent(vo.Aid);
            //    if (vo.EventsModel != null)
            //    {
            //        vo.Cid = vo.EventsModel.ColumnID;
            //        vo.Tid = (vo.EventsModel.TemplateID.HasValue) ? vo.EventsModel.TemplateID.Value : 0;
            //    }
            //}
            
            //获取模板
            if (vo.Tid > 0)
            {
                ModelManageBLL mmb = new ModelManageBLL();
                vo.TempInfo = mmb.getModel(vo.Tid);
            }

            if (vo.TempInfo == null) return "<font color='red'>无模板页</font>";
            CommonModel model = GetModel(int.Parse(vo.TempInfo.ItemID), vo);

            return model.GetHtml();
        }

        internal static CommonModel GetModel(int type, CmsVo vo)
        {
            CommonModel model = null;
            switch (type)
            {
                case 2: // 活动详情
                    model = new EventsTemplateType(vo);
                    break;
                case 5:
                    model = new SponsorTemplateModel(vo);
                    break;
            }
            return model;
        }

    }
}
